package com.fnzn.entranceGuard.service.ths.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.fnzn.entranceGuard.entity.power.PowerHour;
import com.fnzn.entranceGuard.entity.ths.ThsHour;
import com.fnzn.entranceGuard.mapper.ths.ThsHourMapper;
import com.fnzn.entranceGuard.service.ths.IThsHourService;
import com.netflix.discovery.converters.Auto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author sxf
 * @since 2019-01-22
 */
@Service
public class ThsHourServiceImpl extends ServiceImpl<ThsHourMapper, ThsHour> implements IThsHourService {
    @Autowired
    private ThsHourMapper hourMapper;

    @Override
    public ThsHour getByDateHour(String deviceId, String date, Integer hour, String powerId) {
        Wrapper wrapper = new EntityWrapper();
        wrapper.eq("device_id",deviceId);
        wrapper.eq("date",date);
        wrapper.eq("hour",hour);
        wrapper.eq("power_id",powerId);
        List<ThsHour> list = hourMapper.selectList(wrapper);
        if(list!=null && !list.isEmpty()){
            return list.get(0);
        }
        return null;
    }
}
